package cn.dglydrpy.study.webserver.servlet;

import java.io.File;

import cn.dglydrpy.study.webserver.core.Constant;
import cn.dglydrpy.study.webserver.http.HttpRequest;
import cn.dglydrpy.study.webserver.http.HttpResponse;

/**
 * 所有Servlet的超类.规定所有Servlet都应具备的 功能.
 */
public abstract class HttpServlet {
	/**
	 * 该方法用来处理业务逻辑
	 * @param request
	 * @param response
	 */
	public abstract void service(HttpRequest request, HttpResponse response);

	/**
	 * 转发
	 * @param url
	 * @param request
	 * @param response
	 */
	public void forward(String url, HttpRequest request, HttpResponse response) {
		File file = new File(Constant.WEBAPPS_DIR + url);
		response.setEntity(file);
	}
}
